<script>
var mt_idArray = [];
</script>
<div class="SipeiInfo pt20"><!--学生在籍人数设置-学生在籍人数明细编辑-弹窗-新增-->
    <form method='post' action='<?php echo $this->createUrl('/membership/default/subordinatedit') ?>' id="searchForm" target="ajax-frame">
        <?php
        $mn_id = $mt_id = $mt_num = array();
        $school_id = '';
        if ($membershiptype) {
            foreach ($membershiptype as $key => $one) {
                $mt_id[$key] = $one['mt_id'];
                $mt_num[$one['mt_id']] = '';
            }
        }
        if ($membershipnuminfo) {
            $mt_id = $mt_num = array();
            foreach ($membershipnuminfo as $key => $one) {
                $mn_id[] = $one['mn_id'];
                $school_id = $one['school_id'];
                $mt_id[$one['mn_id']] = $one['mt_id'];
                $mt_num[$one['mt_id']] = $one['mt_num'];
            }
        }
        ?>
        <table class="fontc_666 height32">
            <tbody>
                <tr height="55">
                    <?php if ($mn_id):foreach ($mn_id as $key => $one): ?>
                    <input type="hidden" name="mn_id[]" value="<?php echo $one; ?>">
                    <?php
                endforeach;
            else:
                ?>
                <input type="hidden" name="mn_id" value="">
            <?php endif; ?>
            <input type="hidden" name="membership_id" value="<?php echo $membership_id; ?>">
            <td valign="top" width="125" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属学校：</td>
            <td valign="top" width="370" class="formValidator_td">            
                <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                    <span class="fl select_shelter">
                        <select class="fl fontc_666" name="school_id" id="school_id">
                            <option value="0">请选择</option>
                            <?php if ($school):foreach ($school as $key => $one): ?>
                                    <option value="<?php echo $one['school_id'] ?>" <?php
                                    if ($school_id == $one['school_id']) {
                                        echo "selected";
                                    }
                                    ?>><?php echo $one['school_name'] ?></option>
                                            <?php
                                        endforeach;
                                    endif;
                                    ?>
                        </select>
                    </span>
                </span>
                <div class="formValidator_tip">
                    <p id="school_idTip" ></p>
                </div>
            </td>
            </tr>
            <?php if ($membershiptype): foreach ($membershiptype as $key => $one): ?>
                    <tr height="55">
                        <td valign="top" align="right" class="pr5"><input type="hidden" value="<?php echo $one['mt_id']; ?>" name="mt_id[<?php echo $key; ?>]">
                        <?php echo $one['mt_name'] ?>：</td>
                        <td valign="top" class="formValidator_td">
                        	<input type="text" id="mt_id<?php echo $key; ?>" value="<?php echo (!empty($mt_num[$one['mt_id']])) ? $mt_num[$one['mt_id']] : '' ; ?>" name="mt_num[<?php echo $key; ?>]" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666"  />
                        	<div class="formValidator_tip">
                                    <p id="mt_id<?php echo $key; ?>Tip" ></p>
                                </div>
                                <script type="text/javascript">
                                        mt_idArray.push( 'mt_id<?php echo $key; ?>' );
                                </script>
                        </td>
                    </tr>
                    <?php
                endforeach;
            endif;
            ?>
            <tr>
			<input type="hidden" value="<?php echo $school_id;?>" name="is_update" >
                <td align="right" class="pr5 pb20"></td>
                <td class="pb20">
                    <input type="submit" value="保存" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor mr10" />
                    <input type="button" value="取消" onclick="api.close()" class="b_a_n border_3 back_bgb w80 height32 fontc_FFF fonts_12 cursor" />
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
                    $(function() {
                        $.formValidator.initConfig({formID: "searchForm", theme: "126", submitOnce: false,
                            onError: function(msg, obj, errorlist) {
                                $("#errorlist").empty();
                                $.map(errorlist, function(msg) {
                                    $("#errorlist").append("<li>" + msg + "</li>")
                                });
                                alert(msg);
                            },
                            ajaxPrompt: '有数据正在异步验证，请稍等...'
                        });




	/*所属学校验证*/
	$("#school_id").formValidator({
		onShowText:"请输入所属学校",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"所属学校不能为空"
	});
	for( var i=0; i<mt_idArray.length; i++ ){
		/*科目人数*/
		$("#"+mt_idArray[i]).formValidator({
			empty:true,
			onShowText:"",
			onShow:"",
			onFocus:"",
			onCorrect:"输入正确",
			leftTrim:true,
			rightTrim:true
		}).regexValidator({
			regExp: "intege1",
			dataType: "enum",
			onError: "科目人数必须是正整数"
		});;
	}
})
</script>
<?php exit; ?>